/**
	Copyright (c) 2009 Ozazo Pvt Ltd, INDIA

	Permission is hereby granted, free of charge, to any person or organization 
	obtaining a copy of this software and associated  documentation  files (the 
	"Software"), to deal in the Software without restriction, including without 
	limitation the rights to use, copy, modify, merge, publish, distribute, sub
	license, and/or sell copies of the Software, and to permit persons  to whom 
	the Software is furnished to do so, subject to the following conditions:
	
	The above copyright notice and  this permission notice shall be included in 
	all copies or substantial portions of the Software.
	
	THE SOFTWARE IS PROVIDED "AS IS",  WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
	IMPLIED, INCLUDING  BUT NOT  LIMITED  TO THE WARRANTIES OF MERCHANTABILITY,
	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
	AUTHORS OR  COPYRIGHT  HOLDERS  BE  LIABLE  FOR ANY CLAIM, DAMAGES OR OTHER
	LIABILITY,  WHETHER  IN  AN  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
	FROM,  OUT  OF  OR  IN  CONNECTION  WITH  THE  SOFTWARE OR THE USE OR OTHER 
	DEALINGS IN THE SOFTWARE.
 */
package com.ozazo.wave.robots.fw.config;

import java.util.ArrayList;
import java.util.List;


/**
 * RobotConfig.java
 *
 * @author:  Araf Karsh Hamid
 * @date:    
 * @serial:  20091129173023
 * @version: 1.0
 *
 */
public class RobotConfig {

	private String version;
	private List<ContainerConfig> containers;
	
	public RobotConfig(final String _version) {
		version		= (_version != null) ? _version : "1.0";
		containers	= new ArrayList<ContainerConfig>(3);
	}
	
	public void addContainer(ContainerConfig _container) {
		if(_container != null) {
			containers.add(_container);
		}
	}
	
	public List<ContainerConfig> getContainers() {
		return containers;
	}
	
	public String toXMLString() {
		StringBuilder sb = new StringBuilder();
		/**
		<Container isEnabled="True">
			<debug isEnabled="False" />
			<RobotDetails />
			<Parser />
			<Engines>
				<Engine isEnabled="Yes" />
			</Engines>
		</Container>
		 */
		sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
		sb.append(
		"<!-- \n" 
		+"	Copyright (c) 2009 Ozazo Pvt Ltd, INDIA\n"
		+"\n"
		+"	Permission is hereby granted, free of charge, to any person or organization\n" 
		+"	obtaining a copy of this software and associated  documentation  files (the\n" 
		+"	\"Software\"), to deal in the Software without restriction, including without\n" 
		+"	limitation the rights to use, copy, modify, merge, publish, distribute, sub\n"
		+"	license, and/or sell copies of the Software, and to permit persons  to whom\n" 
		+"	the Software is furnished to do so, subject to the following conditions:\n"
		+"	\n"
		+"	The above copyright notice and  this permission notice shall be included in\n" 
		+"	all copies or substantial portions of the Software.\n"
		+"	\n"
		+"	THE SOFTWARE IS PROVIDED \"AS IS\",  WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n"
		+"	IMPLIED, INCLUDING  BUT NOT  LIMITED  TO THE WARRANTIES OF MERCHANTABILITY,\n"
		+"	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n"
		+"	AUTHORS OR  COPYRIGHT  HOLDERS  BE  LIABLE  FOR ANY CLAIM, DAMAGES OR OTHER\n"
		+"	LIABILITY,  WHETHER  IN  AN  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n"
		+"	FROM,  OUT  OF  OR  IN  CONNECTION  WITH  THE  SOFTWARE OR THE USE OR OTHER\n" 
		+"	DEALINGS IN THE SOFTWARE.\n"
		+"-->\n");
		sb.append("<RobotConfig version=\"").append(version).append("\">\n");
		sb.append(
		"<!--\n"  
		+"	A container consists of the following\n"
		+"\n"
		+"	1. Blip Data Parser to parse the blip in real-time (DOCUMENT_CHANGE) and\n" 
		+"	   and non real-time (BLIP_SUBMITTED) mode.\n"
		+"	2. Set of Engines to process the commands and replace the text in the\n"
		+"	   Blip\n"
		+"-->\n"	
		);
		for(ContainerConfig c : containers) {
			sb.append(c.toXMLString());
		}
		sb.append("</RobotConfig>\n");
		return sb.toString();
	}	
}
